import request from '@/utils/request';
import { baseurl } from './baseurl';
export interface addDynamicParams {
  content: any;
  title: string;
  cover:any;
}
export async function addDynamic(params: addDynamicParams) {
  /* 添加动态 */
  const data = new FormData();
  data.append('content', params.content);
  data.append('title', params.title);
  if(params.cover){
    data.append('cover', params.cover);
  }
  return request(`${baseurl}index/index/dynamic`, {
    method: 'POST',
    data,
  });
}
export interface getDynamicParams {
  page: any;
}
export async function getDynamic(params: getDynamicParams) {
  /* 获取动态 */
  const data = new FormData();
  data.append('page', params.page);
  return request(`${baseurl}index/index/dynamic_list`, {
    method: 'POST',
    data,
  });
}

export interface editDynamicParams {
  id: any;
  title: any;
  content: any;
  cover:any
}
export async function editDynamic(params: editDynamicParams) {
  /* 编辑动态 */
  const data = new FormData();
  data.append('id', params.id);
  data.append('title', params.title);
  data.append('content', params.content);
  data.append('type', '1');
  if(params.cover){
    data.append('cover', params.cover);
  }
  return request(`${baseurl}index/index/dynamic_up`, {
    method: 'POST',
    data,
  });
}

export interface deleteDynamicParams {
  id: any;
}
export async function deleteDynamic(params: deleteDynamicParams) {
  /* 删除动态 */
  const data = new FormData();
  data.append('id', params.id);
  data.append('type', '2');
  return request(`${baseurl}index/index/dynamic_up`, {
    method: 'POST',
    data,
  });
}

export interface getDynamicDetailParams {
  id: any;
}
export async function getDynamicDetail(params: getDynamicDetailParams) {
  /* 获取动态详情 */
  const data = new FormData();
  data.append('id', params.id);
  data.append('type', '');
  return request(`${baseurl}index/index/dynamic_up`, {
    method: 'POST',
    data,
  });
}

export interface addPolicyParams {
  name: any;
  sort:any;
  doc:any;
  cover:any;
}
export async function addPolicy(params: addPolicyParams) {
  /* 添加政策法规 */
  const data = new FormData();
  data.append('title', params.name);
  data.append('sort', params.sort);
  data.append('doc', params.doc);
  data.append('cover', params.cover);

  return request(`${baseurl}index/index/policy`, {
    method: 'POST',
    data,
  });
}

export interface getPolicyListParams {
    page: any;
    name:any;
}
export async function getPolicyList(params: getPolicyListParams) {
  /* 政策法规列表 */
  const data = new FormData();
  data.append('page', params.page);
  data.append('title', params.name);

  return request(`${baseurl}index/index/policy_list`, {
    method: 'POST',
    data,
  });
}

export interface editPolicyParams {
  id: any;
  name: any;
  sort:any;
  doc:any;
  cover:any;
}
export async function editPolicy(params: editPolicyParams) {
  /* 编辑政策法规 */
  const data = new FormData();
  data.append('id', params.id);
  data.append('title', params.name);
  data.append('sort', params.sort);
  data.append('doc', params.doc);
  data.append('cover', params.cover);
  data.append('type','1')
  return request(`${baseurl}index/index/policy_up`, {
    method: 'POST',
    data,
  });
}
export interface deletePolicyParams {
  id: any;
}
export async function deletePolicy(params: deletePolicyParams) {
  /* 删除政策法规 */
  const data = new FormData();
  data.append('id', params.id);
  data.append('type', '2');
  return request(`${baseurl}index/index/policy_up`, {
    method: 'POST',
    data,
  });
}


export interface addPlanParams {
  content: any;
  title: string;
  stick: string;
  cover:any;
}
export async function addPlan(params: addPlanParams) {
  /* 添加考试计划 */
  const data = new FormData();
  data.append('content', params.content);
  data.append('title', params.title);
  data.append('stick', params.stick);
  if(params.cover){
    data.append('cover', params.cover);
  }
  return request(`${baseurl}index/index/examination`, {
    method: 'POST',
    data,
  });
}
export interface getPlanParams {
  page: any;
}
export async function getPlan(params: getPlanParams) {
  /* 获取考试计划 */
  const data = new FormData();
  data.append('page', params.page);
  return request(`${baseurl}index/index/examination_list`, {
    method: 'POST',
    data,
  });
}

export interface editPlanParams {
  id: any;
  title: any;
  content: any;
  stick: any;
  cover:any;
}
export async function editPlan(params: editPlanParams) {
  /* 编辑考试计划 */
  const data = new FormData();
  data.append('id', params.id);
  data.append('title', params.title);
  data.append('content', params.content);
  data.append('stick', params.stick);
  if(params.cover){
    data.append('cover', params.cover);
  }
  data.append('type', '1');
  return request(`${baseurl}index/index/dynamic_up`, {
    method: 'POST',
    data,
  });
}

export interface deletePlanParams {
  id: any;
}
export async function deletePlan(params: deletePlanParams) {
  /* 删除考试计划 */
  const data = new FormData();
  data.append('id', params.id);
  data.append('type', '2');
  return request(`${baseurl}index/index/dynamic_up`, {
    method: 'POST',
    data,
  });
}

export interface getPlanDetailParams {
  id: any;
}
export async function getPlanDetail(params: getPlanDetailParams) {
  /* 获取考试计划详情 */
  const data = new FormData();
  data.append('id', params.id);
  data.append('type', '');
  return request(`${baseurl}index/index/dynamic_up`, {
    method: 'POST',
    data,
  });
}
